<template>
  <PageWrapper>
    <BasicTable @register="registerTable">
      <template #tableTitle> </template>
      <template #bodyCell="{ column, record, text }">
        <template v-if="column.dataIndex === 'operate'">
          <a-button type="link" class="g-operate-btn" v-auth="permissionCodeMap.logView" @click="openView(record)">
            查看
          </a-button>
        </template>
      </template>
    </BasicTable>
    <ViewLog @register="viewRegister" />
  </PageWrapper>
</template>

<script lang="ts" setup>
import { reactive, ref, computed, unref, watch } from 'vue'
import PageWrapper from '@/components/PageWrapper/index.vue'
import { BasicTable, useTable } from '@/components/Table'
import { getLogsBasicColumns, getSearchFormConfig } from './dataSource'
import { useDrawer } from '@/components/Drawer'
import ViewLog from './components/ViewLog.vue'
import { constantMap } from '@/types/enum'
import { permissionCodeMap } from '@/utils/permissionCodeMap'
import { LogRecord } from '@/types/system'
import { message } from 'ant-design-vue'
import api from '@/api'
const { logsList } = api

const [viewRegister, { openDrawer: viewOpenDrawer }] = useDrawer()
const [registerTable, { reload, setPagination }] = useTable({
  api: logsList,
  columns: getLogsBasicColumns(),
  useSearchForm: true,
  formConfig: getSearchFormConfig(),
  scroll: { y: constantMap.tableYHeight, x: constantMap.tableXWidth }
})

const openView = (record: LogRecord) => {
  viewOpenDrawer(true, { record })
}
</script>

<style lang="less" scoped></style>
